package oa.hleast.xswl.controller.admin;

import oa.hleast.xswl.service.ISysRouteTitleService;
import oa.hleast.common.result.Result;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiImplicitParam;
import io.swagger.annotations.ApiOperation;
import lombok.AllArgsConstructor;
import lombok.SneakyThrows;
import lombok.extern.slf4j.Slf4j;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;

import javax.validation.constraints.NotBlank;

@Api(tags = "【提供服务】页面路由映射")
@RestController
@RequestMapping("/api.admin/v1/routeTitle")
@Slf4j
@AllArgsConstructor
public class SysRouteTitleController {

    private final ISysRouteTitleService sysRouteTitleService;

    @ApiOperation(value = "根据路由获取title -其他服务调用")
    @ApiImplicitParam(name = "route", value = "界面路由", required = true, paramType = "query", dataType = "String", dataTypeClass = String.class)
    @PostMapping("/getTitleByRoute")
    @SneakyThrows
    public Result<String> getTitleByRoute(@RequestParam @NotBlank String route) {
        String title = sysRouteTitleService.getTitleByRoute(route);
        return Result.success(title);
    }
}
